package data;

import java.util.regex.Pattern;

public class UserAccount {
	private String accountName;
	private String accountPassword;
	private String accountEmail;
	private int accountPhone;
	private Carrier carrier;

	private static final Pattern EMAIL_CHECK = Pattern.compile(
			"^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$",
			Pattern.CASE_INSENSITIVE);

	public UserAccount(String accountName, String accountPassword) {
		this(accountName, accountPassword, null, 0, null);
	}

	public UserAccount(String accountName, String accountPassword, String accountEmail) {
		this(accountName, accountPassword, accountEmail, 0, null);
	}

	public UserAccount(String accountName, String accountPassword, String accountEmail, int accountPhone,
			Carrier carrier) {
		super();
		this.accountName = accountName;
		this.accountPassword = accountPassword;
		this.accountEmail = accountEmail;
		this.accountPhone = accountPhone;
		this.carrier = carrier;
	}

	public String getAccountName() {
		return accountName;
	}

	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	public String getAccountPassword() {
		return accountPassword;
	}

	public void setAccountPassword(String accountPassword) {
		this.accountPassword = accountPassword;
	}

	public String getAccountEmail() {
		return accountEmail;
	}

	public void setAccountEmail(String accountEmail) {
		this.accountEmail = accountEmail;
	}

	public boolean validEmailFormat() {
		return accountEmail != null ? EMAIL_CHECK.matcher(accountEmail).matches() : false;
	}

	public int getAccountPhone() {
		return accountPhone;
	}

	public void setAccountPhone(int accountPhone) {
		this.accountPhone = accountPhone;
	}

	public Carrier getCarrier() {
		return carrier;
	}

	public void setCarrier(Carrier carrier) {
		this.carrier = carrier;
	}
}
